<?php

namespace app\validate\adm;

use think\Validate;

class CarProtectValidate extends Validate
{
    /**
     * 定义验证规则
     * @var array
     */
    protected $rule = [
        'car_id' => 'require|integer|gt:0',
        'protect_date' => 'require|date',
        'protect_type' => 'require|in:1,2,3,4',
        'protect_content' => 'require|max:500',
        'protect_cost' => 'float|egt:0',
        'protect_shop' => 'max:100',
        'next_protect_date' => 'date',
        'next_protect_mileage' => 'integer|egt:0',
        'remark' => 'max:500',
    ];

    /**
     * 定义错误信息
     * @var array
     */
    protected $message = [
        'car_id.require' => '车辆ID不能为空',
        'car_id.integer' => '车辆ID必须是整数',
        'car_id.gt' => '车辆ID必须大于0',
        'protect_date.require' => '保养日期不能为空',
        'protect_date.date' => '保养日期格式不正确',
        'protect_type.require' => '保养类型不能为空',
        'protect_type.in' => '保养类型值不正确',
        'protect_content.require' => '保养内容不能为空',
        'protect_content.max' => '保养内容不能超过500个字符',
        'protect_cost.float' => '保养费用必须是数字',
        'protect_cost.egt' => '保养费用不能为负数',
        'protect_shop.max' => '保养店名称不能超过100个字符',
        'next_protect_date.date' => '下次保养日期格式不正确',
        'next_protect_mileage.integer' => '下次保养里程必须是整数',
        'next_protect_mileage.egt' => '下次保养里程不能为负数',
        'remark.max' => '备注不能超过500个字符',
    ];

    /**
     * 定义验证场景
     * @var array
     */
    protected $scene = [
        'add' => ['car_id', 'protect_date', 'protect_type', 'protect_content', 'protect_cost', 'protect_shop', 'next_protect_date', 'next_protect_mileage', 'remark'],
        'edit' => ['id', 'car_id', 'protect_date', 'protect_type', 'protect_content', 'protect_cost', 'protect_shop', 'next_protect_date', 'next_protect_mileage', 'remark'],
    ];
}